#include <cubefs/api/api.hpp>
#include <natives.h>
#include <decls.hpp>
#include <exceptions.hpp>

#include <cubefs/core/tools/types/dispatcher.hpp>

#define CUBEFS_SOURCE "id.cpp:" CUBEFS_AT

using namespace cubefs::api;
using namespace cubefs::tools;

using namespace std;

JNIEXPORT jstring JNICALL REFLECTION_PKG(TypedIDValue, text) (JNIEnv *env, jclass, jlong handle) {
    CUBEFS_EXC_BEGIN

    TypedIDValue* value = Handle2Ptr<TypedIDValue>(handle);
    return env->NewStringUTF(value->GetValue().str().c_str());

    CUBEFS_EXC_HANDLE
    return NULL;
}

JNIEXPORT jboolean JNICALL VALUE_PKG(TypedIDValue, isNull) (JNIEnv *env, jclass, jlong handle) {
    CUBEFS_EXC_BEGIN

    TypedIDValue* value = Handle2Ptr<TypedIDValue>(handle);
    return value->GetValue().IsNull();

    CUBEFS_EXC_HANDLE
    return NULL;
}


JNIEXPORT jboolean JNICALL VALUE_PKG(TypedIDValue, equals) (JNIEnv *env, jclass, jlong me, jlong otherh) {
    CUBEFS_EXC_BEGIN

    TypedIDValue* value = Handle2Ptr<TypedIDValue>(me);
    TypedIDValue* other = Handle2Ptr<TypedIDValue>(otherh);
    return value->GetValue().equals(other->GetValue());

    CUBEFS_EXC_HANDLE
    return NULL;
}

#undef CUBEFS_SOURCE
